<?php
class friendlog_model extends CI_Model {
	
	function add_friendlog($fuid,$note){
		$log_data=array(
				'user_id'=>$this->session->userdata('user_id'),
				'fuid'=>$fuid,
				'action'=>'add',
				'note'=>$note
		);
		
		$query=$this->db->insert('friendlog',$log_data);
		return $query;
	}
	
	function get_request_log($limit="",$offset=""){
		$user_id=$this->session->userdata('user_id');
		
		$this->db->where('fuid',$user_id);
		$this->db->where('action','add');
		$query=$this->db->get('friendlog',$limit,$offset);
		if($query->num_rows()==0)
			return false;
		else
			return $query->result();
		
	}
	
	function concept($id){
		$this->db->where('user_id',$id);
		$this->db->where('fuid',$this->session->userdata('user_id'));
		$query=$this->db->update('friendlog',array("action"=>"concept"));
		
		if($query)
			return true;
		else
			return false;
	}
	
	function refuse($id){
		$this->db->where('user_id',$id);
		$this->db->where('fuid',$this->session->userdata('user_id'));
		$query=$this->db->update('friendlog',array("action"=>"refuse"));
		if($query)
			return true;
		else
			return false;
	}
}
